package org.stratusdb.funsql.compile.predicate;

import java.util.Vector;


public class ComplexPredicate extends AbstractPredicate{
	
	private Vector<AbstractPredicate> predicates = new Vector<AbstractPredicate>();
	private static ComplexPredicate instance;
	
	public ComplexPredicate() {
		super();
	}
	
	public static ComplexPredicate getInstance() {
		if(instance == null) {
			instance = new ComplexPredicate();
		}
		return instance;
	}
	
	public static void resetInstance() {
		instance = null;
	}
	
	public void addSPA(SimplePredicateAttribute spa) {
		this.predicates.add(spa);
	}
		
	public void addSPL(SimplePredicateLiteral spl) {
		this.predicates.add(spl);
	}
	public Vector<AbstractPredicate> getComplexPredicate(){
		return this.predicates;
	}
	
	@Override
	public String toSqlString() {
		StringBuffer sb = new StringBuffer("Complex Predicate list: \n");
		for(AbstractPredicate ap : this.predicates) {
			sb.append(ap.toSqlString()+"\n");
		}
		return sb.toString();
	}
}
